package net.wxxr.http.auth;

import oauth.signpost.OAuthConsumer;
import oauth.signpost.exception.OAuthCommunicationException;
import oauth.signpost.exception.OAuthExpectationFailedException;
import oauth.signpost.exception.OAuthMessageSignerException;

import org.apache.http.client.methods.HttpRequestBase;

/**
 * IAuthSign 的默认实现，用户在调用HttpBaseRequest的sign(IAuthSign sign)方法时如传空值，则会使用此实现
 * @author yuanwenfei
 */
public class BaseAuthSign implements IAuthSign {

	protected OAuthConsumer consumer;
	
	public OAuthConsumer getConsumer() {
		return consumer;
	}

	public void setConsumer(OAuthConsumer consumer) {
		this.consumer = consumer;
	}

	public BaseAuthSign(OAuthConsumer consumer) {
		this.consumer = consumer;
	}
	
	@Override
	public void sign(HttpRequestBase requestBase) throws OAuthMessageSignerException, OAuthExpectationFailedException, OAuthCommunicationException {
		if(consumer != null) {
			consumer.sign(requestBase);
		}
	}

	
}
